#!/usr/bin/python
# -*- encoding: utf-8 -*-
'''
@File    :   1.py
@Time    :   2020/05/22 14:40:11
@Author  :   Malygos_l 
@Version :   1.0
@Contact :   751756061@qq.com
@WebSite :   www.gitee.com/malygos_l
'''

# 编写一个装饰器，能计算其他函数的运行时间；
# Start typing your code from here

import time
from random import randint
from datetime import datetime,timedelta

def caculate_time(func):
    def inner():
        start_time = datetime.now()
        func()
        end_time = datetime.now()
        time = end_time - start_time
        print("运行时间:%s" % time)
    return inner

@caculate_time
def index():    
    time.sleep(randint(1,5))
    print("welcome to index page")

def main():
    # index = caculate_time(index)
    index()

if __name__ == "__main__":
    main()